import { Global, Module } from '@nestjs/common';
import { AuthService } from './auth/auth.service';
import { JwtModule } from '@nestjs/jwt';
import { ConfigModule, ConfigService } from '@nestjs/config';
import CommonConfig from './common.config';

@Global()
@Module({
  providers: [AuthService],
  exports: [AuthService],
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      cache: true,
      load: [CommonConfig],
    }),
    JwtModule.registerAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: async (configService: ConfigService) => {
        const config = configService.get('common.jwt');
        // config.database='your_database_name',
        // console.log(config);

        return config;
      },
    }),
  ],
})
export class CommonModule {}
